/**
 * 数据库字段封装类
 * Created by Ay on 2017/5/3.
 */
public class ColumnClass {
    public static void main(String[] args) {
        String s = "t_dtwdwdw";
        String substring = s.substring(2, s.length() );
        System.out.println(substring);
    }
    /** 数据库字段名称 **/
    private String columnName;
    /** 数据库字段类型 **/
    private String columnType;
    /** 数据库字段首字母小写且去掉下划线字符串 **/
    private String changeColumnName;
    /** 数据库字段注释 **/
    private String columnComment;

    private String javaColumnType;

    public String getJavaColumnType() {

        if(getColumnType().equals("VARCHAR") || getColumnType().equals("CHAR")|| getColumnType().equals("LONGVARCHAR")){
            return "String";
        }else if(getColumnType().equals("TIMESTAMP") || getColumnType().equals("TIME")||
                getColumnType().equals("DATETIME")||getColumnType().equals("DATE")){
            return "Date";
        }else if(getColumnType().equals("INTEGER") || getColumnType().equals("INTEGER UNSIGNED")){
            return "Integer";
        }else if(getColumnType().equals("BIGINT")|| getColumnType().equals("BIGINT UNSIGNED")){
            return "Long";
        }else if(getColumnType().equals("DECIMAL")||getColumnType().equals("NUMERIC")||getColumnType().equals("DECIMAL UNSIGNED")){
            return "BigDecimal";
        }else if(getColumnType().equals("TINYINT") || getColumnType().equals("TINYINT UNSIGNED")){
            return "Integer";
//            return "Byte";
        }else if(getColumnType().equals("SMALLINT")){
            return "Short";
        }else if(getColumnType().equals("FLOAT")||getColumnType().equals("REAL")){
            return "Float";
        }else if(getColumnType().equals("DOUBLE")){
            return "Double";
        }else if(getColumnType().equals("BIT")){
            return "Boolean";
        }
        return "String";
    }

    public String getColumnComment() {
        return columnComment;
    }

    public void setColumnComment(String columnComment) {
        this.columnComment = columnComment;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getColumnType() {
        if(columnType.equals("INT") || columnType.equals("INT UNSIGNED")){
            return "INTEGER";
        }
        if(columnType.equals("TEXT")){
            return "LONGVARCHAR";
        }
        if(columnType.equals("DATETIME")){
            return "TIMESTAMP";
        }
        return columnType;
    }

    public void setColumnType(String columnType) {
        this.columnType = columnType;
    }

    public String getChangeColumnName() {
        return changeColumnName;
    }

    public void setChangeColumnName(String changeColumnName) {
        this.changeColumnName = changeColumnName;
    }
}